<include file="public/layout" />
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>小区管理 - 添加小区</h3>
                <h5>网站系统添加小区</h5>
            </div>
        </div>
    </div>
    <form class="form-horizontal" method="post" id="add_form" enctype="multipart/form-data">
        <div class="ncap-form-default">
            <input type="hidden" name="id" id="id" class="input-txt" value="{$list.id}">
            <dl class="row">
                <dt class="tit">
                    <label for="username"><em>*</em>户主姓名</label>
                </dt>
               <dd class="opt">
                    <select id="uid" name="uid"  title="请选择所在省份">
                        <option value="">选择用户</option>
                        <volist name="user" id="vo">
                            <option value="{$vo.id}" >{$vo.name}</option>
                        </volist>
                    </select>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="consignee"><em>*</em>地址</label>
                </dt>
                <dd class="opt">
                    <select onchange="get_unit(this)" id="com" name="com"  title="请选择所在小区">
                        <option value="">选择小区</option>
                        <volist name="com" id="vo">
                            <option value="{$vo.id}" >{$vo.name}</option>
                        </volist>
                    </select>
                    <select onchange="get_room(this)" id="unit" name="unit" title="请选择所在单元">
                        <option value="">选择单元</option>
                        <volist name="unit" id="vo">
                            <option value="{$vo.id}">{$vo.name}</option>
                        </volist>
                    </select>
                    <select id="room" name="room" title="请选择所在房间号">
                        <option value="">选择房间号</option>
                        <volist name="room" id="vo">
                            <option value="{$vo.id}">{$vo.name}</option>
                        </volist>
                    </select>
                    <!-- <input type="text" name="address" id="address" class="input-txt"   placeholder="详细地址"/> -->
                </dd>
            </dl>
            <div class="bot"><a href="JavaScript:void(0);" onclick="checkUserUpdate();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a></div>
        </div>
    </form>
</div>
<script type="text/javascript">
    function get_unit(t,unit,room,twon){
        var parent_id = $(t).val();
        if(!parent_id > 0){
            return;
        }
        var unit_id = 'unit';
        if(typeof(unit) != 'undefined' && unit != ''){
            unit_id = unit;
        }
        var room_id = 'room';
        if(typeof(room) != 'undefined' && room != ''){
            room_id = room;
        }
        var twon_id = 'twon';
        if(typeof(twon) != 'undefined' && twon != ''){
            twon_id = twon;
        }
        $('#'+room_id).empty().css('display','none');
        $('#'+twon_id).empty().css('display','none');
        var url = '/index.php?m=Home&c=Api&a=getCom&level=5&parent_id='+ parent_id;
        $.ajax({
            type : "GET",
            url  : url,
            error: function(request) {
                alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function(v) {
                v = '<option value="0">单元楼</option>'+ v;
                $('#'+unit_id).empty().html(v);
            }
        });
    }
    /**
     * 获取地区
     * @param t  城市select对象
     * @param room
     * @param twon
     */
    function get_room(t,room,twon){
        var parent_id = $(t).val();
        if(!parent_id > 0){
            return;
        }
        var room_id = 'room';
        if(typeof(room) != 'undefined' && room != ''){
            room_id = room;
        }
        var twon_id = 'twon';
        if(typeof(twon) != 'undefined' && twon != ''){
            twon_id = twon;
        }
        $('#'+room_id).empty().css('display','inline');
        $('#'+twon_id).empty().css('display','none');
        var url = '/index.php?m=Home&c=Api&a=getCom&level=6&parent_id='+ parent_id;
        $.ajax({
            type : "GET",
            url  : url,
            error: function(request) {
                alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function(v) {
                v = '<option>房间号</option>'+ v;
                $('#'+room_id).empty().html(v);
            }
        });
    }



     function checkUserUpdate(){
        $('#add_form').submit();
    }

</script>
</body>
</html>